package com.itheima.health.controller;


import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.OrderDto;
import com.itheima.health.entity.Result;
import com.itheima.health.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/mobile/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /**体检预约-订单数据展示*/
    @GetMapping("/findById")
    public Result findById(Integer id){
        log.info("[体检预约传来id]id:{}",id);
        OrderDto orderDto= orderService.findById(id);
        return new Result(true, MessageConst.QUERY_ORDER_SUCCESS,orderDto);
    }

    @PostMapping("/submit")
    public Result submitOrder(@RequestBody Map map){
        log.info("预约订单信息:{}", map);
        Result result = orderService.addOrder(map);
            return result;

    }

}